<?php
class ControllerMyplanNews extends Controller{
	public function index(){
	
		$this->load->model("myplan/user");
		
		$query=array();
		
		$limit=10;
		
		if(isset($this->request->get["page"])){
			$page=$this->request->get["page"];
		}else{
			$page=1;
		}
		
		$query["start"]=($page-1)*$limit;
		$query["limit"]=$limit;
		$query["user_id"]=$this->user->getId();
		
		$this->data["allfriendsnews"]=$this->model_myplan_user->getFriendsNews($query);
		
		$this->data["viewplan"]=$this->url->link("myplan/viewplan");
		$this->data["checkplan"]=$this->url->link("myplan/checkplan")."&user_id=";
		
				//分页
				$pagination = new Pagination();
				$pagination->total = $this->model_myplan_user->getTotalFriendsNews($query);
				$pagination->page = $page;
				$pagination->limit = $limit;
				$pagination->text = "P";
				$pagination->url = $this->url->link('myplan/news',  $url . '&page={page}');
					
				$this->data['pagination'] = $pagination->render();
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/myplan/news.tpl')) 		            {
				$this->template = $this->config->get('config_template') . '/template/myplan/news.tpl';
			} else {
				$this->template = 'default/template/myplan/news.tpl';
			}
			
			$this->children = array(
			'myplancommon/footer',
			'myplancommon/header'
			);
											
		$this->response->setOutput($this->render());
	}	
	
	public function validate(){
		if($this->request->post["content"]==""){
			$this->data["warning"]="不能为空";
			return false;
		}
	    return true;
	}
}
?>
